from dome5.agent import SmartAgent


def generateToolStory():
    # return {"name":"kadjsfkajdjkf"}
    agent = SmartAgent()
    agent.registerTool(
        "generateStory",
        "这是一个根据传入指定主题生成故事的方法",
        {
            "type": "object",
            "properties": {
                "theme": {
                    "type": "string",
                    "description": "故事具体主题"
                }
            },
            "required": ["theme"]
        },
        lambda theme: f"根据你的主题{theme},我们生成了这样一个故事：小白兔白又白，两只耳朵竖起来，爱吃萝卜爱吃菜，蹦蹦跳跳真可爱"
    )
    agent.registerTool(
        "formatStory",
        "格式化传入的故事内容为统一格式，并返回格式化后的故事",
        {
            "type": "object",
            "properties": {
                "content": {
                    "type": "string",
                    "description": "生成的故事的详细内容"
                }
            },
            "required": ["content"]
        },
        lambda content: f"小白兔白又白，两只耳朵竖起来，爱吃萝卜爱吃菜，蹦蹦跳跳真可爱"
    )
    agent.registerTool(
        "publishStory",
        "格式化好的故事发布到博客",
        {
            "type": "object",
            "properties": {
                "content": {
                    "type": "string",
                    "description": "格式化好的具体故事内容"
                }
            },
            "required": ["content"]
        },
        lambda content: f"我们已经将故事发布到博客"
    )
    prompt = "生成一篇乌龟找绿豆的故事并发布到博客"
    result = agent.run(prompt)
    return {"result": result}
